var t = getApp();

Page({
    data: {
        language: "",
        cash: "",
        withdraw_amount: "",
        withdraw_limit: null
    },
    onLoad: function(t) {
        var a = wx.getStorageSync("langIndex");
        this.setData({
            language: a.en
        }), this.getData();
    },
    getData: function() {
        var a = this, i = t.getNetAddresss("plugin.team-sideways.frontend.withdraw.index");
        t._getNetWork({
            url: i,
            success: function(t) {
                1 === t.data.result ? a.setData({
                    withdraw_amount: t.data.data.withdraw_amount || 0,
                    withdraw_limit: t.data.data.withdraw_limit
                }) : wx.showToast({
                    title: t.data.msg,
                    icon: "none"
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    cashBtn: function(t) {
        var a = t.detail.value;
        this.setData({
            cash: a
        });
    },
    sureCash: function() {
        if (Number(this.data.withdraw_amount) < Number(this.data.withdraw_limit)) wx.showToast({
            icon: "none",
            title: "提现金额不足",
            duration: 1e3
        }); else if (Number(this.data.cash) > Number(this.data.withdraw_amount)) wx.showToast({
            icon: "none",
            title: "提现金额超出",
            duration: 1e3
        }); else if (this.data.withdraw_limit && Number(this.data.cash) < Number(this.data.withdraw_limit)) wx.showToast({
            icon: "none",
            title: "提现金额不小于".concat(this.data.withdraw_limit),
            duration: 1500
        }); else if (Number(this.data.cash) < 0) wx.showToast({
            icon: "none",
            title: "输入的提现数额需大于0",
            duration: 1500
        }); else {
            var a = t.getNetAddresss("plugin.team-sideways.frontend.withdraw.handle");
            t._getNetWork({
                url: a,
                data: {
                    amount: Number(this.data.cash).toFixed(2)
                },
                success: function(t) {
                    var a = t.data;
                    1 == a.result ? (wx.showToast({
                        icon: "none",
                        title: "提现成功",
                        duration: 1500
                    }), wx.navigateBack({
                        delta: 1
                    })) : wx.showToast({
                        icon: "none",
                        title: a.msg,
                        duration: 1500
                    });
                }
            });
        }
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {}
});